package com.theyeasy.dvmini.pc.controller;

import java.math.BigDecimal;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.theyeasy.dvmini.model.Activity;
import com.theyeasy.dvmini.service.ActivityService;
import com.theyeasy.dvmini.vo.Vo_msg;

@Controller
@RequestMapping("/activity")
public class ActivityController extends BaseController {

    @Autowired
    ActivityService activityService;
    
     
    
    
   
    
    @RequestMapping("/activityindex")
    public ModelAndView activityindex() {
        ModelAndView mv = new ModelAndView("/pc/activity/activityindex");
        return mv;
    }
    
    //修改活动配置
    @RequestMapping(value = "/editActivitySetting")
    @ResponseBody
    public Object editActivitySetting(String beginTime,
            BigDecimal planMny,Integer minMny,Integer maxMny,Integer lotteryPercent
            ,String city,String keyword,String unLotteryReply,String finishReply
            ,String lotteryTitle,String lotterySubTitle) {
       String result =activityService.editActivitySetting(beginTime, planMny, minMny, maxMny, lotteryPercent, city, keyword, unLotteryReply, finishReply, lotteryTitle, lotterySubTitle);
        if (result.equals("ok")) {
            return new Vo_msg(0,null, "操作成功");
        } else {
            return new Vo_msg(-1,null, result);
        }
       
    }

    //修改活动状态
    @RequestMapping(value = "/updateActivityStatus")
    @ResponseBody
    public Object updateActivityStatus(Integer status) {
        String result =activityService.updateActivityStatus(status);
        if (result.equals("ok")) {
            return new Vo_msg(0,null, "操作成功");
        } else {
            return new Vo_msg(-1,null, result);
        }
    }

    // 获取
    @RequestMapping(value = "/getActivitySetting")
    @ResponseBody
    public Object getActivitySetting() {
        Activity activity =activityService.getActivitySetting();
        if (activity != null) {
            return new Vo_msg(0, activity);
        } else {
            return new Vo_msg(-1, "获取失败，数据为空");
        }
    }
   
   
    //设置活动下一轮
    @RequestMapping(value = "/clearActivity")
    @ResponseBody
    public Object clearActivity() {
        String result=activityService.clearActivity();
        if (result.equals("ok")) {
            return new Vo_msg(0,null, "操作成功");
        } else {
            return new Vo_msg(-1,null, result);
        }
    }
    
    //中奖记录
    @RequestMapping(value = "/getLotteryLogList", method = RequestMethod.POST)
    public @ResponseBody Object getLotteryLogList(Integer page, Integer pagesize,Integer turn,String keyword) {
     return new Vo_msg(0,activityService.getLotteryLogList(page, pagesize, turn, keyword));    
    }
}
